package adv7;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

public class SaveThread extends Thread {
	private Company c;

	public SaveThread(Company c) {
		this.c = c;
	}

	@Override
	public void run() {
		while (true) {
			try {
				sleep(3000);
				ObjectOutputStream oos = null;
				oos = new ObjectOutputStream(new FileOutputStream(
						"company.info"));
				// // 对象序列化 写入流
				oos.writeObject(c);
				oos.close();// 写在一起的话 oos提前关闭

			} catch (Exception e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}

		}
	}
}
